package day_06;

/**
 * @ClassName CommonMeasure
 * @Description TODO
 * @Author hp
 * @Date 2021/6/8 15:39
 * @Version 1.0
 **/
public class CommonMeasure {
    public static void main(String[] args) {
        int[] nums = new int[]{10,15,20,25,30};
        int i = getCM(nums);
        System.out.println("i = " + i);
    }

    public static int getCM(int[] a ){
        int min = a[0];
        int target = 0;
        for (int i = 0; i < a.length; i++) {
           min = min < a[i]?min:a[i];
        }

        for (int i = min; i >0; i--) {
            boolean flag = true;
            for (int j = 0; j < a.length; j++) {
                if(a[j]%i!=0){
                    flag=false;
                }
            }
            if (flag){
                target = i;
                break;
            }
        }
        return target;
    }
}
